package io.bigbird0101.order.business.service.impl;

import cn.hutool.core.bean.BeanUtil;
import io.bigbird0101.order.business.service.dto.OrderDto;
import io.bigbird0101.order.business.service.entity.Order;
import io.bigbird0101.order.business.service.mapper.OrderMapper;
import io.bigbird0101.order.business.service.vo.OrderVo;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author bigbird-0101
 * @date 2024-04-11 22:37
 */
@Service
@RequiredArgsConstructor
public class OrderService {
    private final OrderMapper orderMapper;
    public OrderVo createOrder(OrderDto order) {
        Order entity = BeanUtil.copyProperties(order, Order.class);
        int insert = orderMapper.insert(entity);
        return BeanUtil.copyProperties(entity,OrderVo.class);
    }

    public OrderVo getOrderById(Long id) {
        Order order = orderMapper.selectById(id);
        return BeanUtil.copyProperties(order,OrderVo.class);
    }
}
